package com.hp.controller;

import com.hp.service.TestService;
import com.hp.util.JsonData;
import com.hp.util.RedisUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("test")
public class TestController {

    @Resource
    TestService testService;
    @Resource
    RedisUtil redisUtil;
    @RequestMapping("/mysql")
    @ResponseBody
    public Object mysql() {
        return JsonData.buildSuccess(testService.test());
    }

    @RequestMapping("/redis")
    @ResponseBody
    public Object redis() {
        redisUtil.set("redis", "测试redis缓存",100);
        System.out.println(redisUtil.getExpire("redis"));
        return JsonData.buildSuccess(redisUtil.get("redis"));
    }
}
